package com.zhsm.fuxi.mvp.ui.dialog

import android.content.Context
import android.view.View
import com.zhsm.fuxi.R
import com.zhsm.fuxi.base.BaseDialog
import kotlinx.android.synthetic.main.dialog_atthint.*
import org.jetbrains.anko.sdk25.coroutines.onClick

/**
 * Created by GuZhC on 2018/11/20.
 */
class HintDialog(context: Context) : BaseDialog(context) {


    override fun getLayoutId(): Int {
        return R.layout.dialog_atthint
    }

    override fun getGravity(): Int {
        return BaseDialog.GRAVITY_CENTER
    }

    override fun isCanceledOnTouchOutside(): Boolean {
        return true
    }

    override fun initView() {
        super.initView()
        attHintOk.onClick {
            mClickBtn?.sureBtn()
        }
        attHintOut.onClick { mClickBtn?.cancelBtn() }
        dialogRoot.onClick { dismiss() }
    }

    override fun dismiss() {
        super.dismiss()
    }

    interface onClickBtn {
        //保存
        fun sureBtn()
        fun cancelBtn()
    }
    private var mClickBtn: onClickBtn? = null

    fun setOnClickAndRes(hintText:String,imgId:Int,cancelVisibility:Boolean,okBtnTExt:String,mClickSave: onClickBtn) {
        attHint.text = hintText
        attHintImg.setImageResource(imgId)
        if (cancelVisibility) attHintOut.visibility = View.VISIBLE
        else  attHintOut.visibility = View.GONE
        attHintOk.text = okBtnTExt
        this.mClickBtn = mClickSave
    }
}